#include"HashTable.h"

namespace MyMap{
    template<class K,class V>
    class UnorderedMap{
        //内部类
        struct MapKeyOfT{
            const K& operator()(const pair<const K,V>& kv){
                return kv.first;
            }
        };
    public:
        typedef typename Hash_bucket::HashTable<K,pair<const K,V>,MapKeyOfT>::iterator iterator;
        typedef typename Hash_bucket::HashTable<K,pair<const K,V>,MapKeyOfT>::const_iterator const_iterator;

        iterator begin(){
            return _hashtable.begin();
        }

        iterator end(){
            return _hashtable.end();
        }

        const_iterator begin()const{
            return _hashtable.begin();
        }

        const_iterator end()const{
            return _hashtable.end();
        }


        pair<iterator,bool> insert(const pair<const K,V>& kv){
            return _hashtable.Insert(kv);
        }

        V& operator[](const K& Key){
            pair<iterator,bool> ret=_hashtable.Insert(make_pair(Key,V()));
            return ret.first->second;
        }

    private:
        Hash_bucket::HashTable<K,pair<const K,V>,MapKeyOfT> _hashtable;
    };
};